﻿using System;
using System.ComponentModel;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Rendiciones.Logica
{
    [DefaultProperty("Text")]
    [ToolboxData("<{0}:ValidationSummary runat=server></{0}:ValidationSummary>")]
    public class ValidationSummary : System.Web.UI.WebControls.ValidationSummary
    {
        protected override void OnInit(EventArgs e)
        {
            this.CssClass = "result_error_vs";
            this.ShowMessageBox = false;
            this.ShowSummary = true;

            base.OnInit(e);
        }

        /// <summary>
        /// Agrega un error al sumario
        /// </summary>
        /// <param name="mensaje"></param>
        public void AddError(string mensaje)
        {
            var custom = new CustomValidator();
            custom.ErrorMessage = mensaje;
            custom.IsValid = false;
            Page.Validators.Add(custom);
        }
    }
}